package br.ufrj.cg.controller;

import java.awt.Cursor;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;

import br.ufrj.cg.view.MainWindow;

public class MainWindowMouseListener implements MouseListener {

	private MainWindow mainWindow;
	
	private MainWindowController mainWindowController;
	
	public MainWindowMouseListener(MainWindow paramMainWindow, MainWindowController paramMainWindowController)
	{
		mainWindow = paramMainWindow;
		mainWindowController = paramMainWindowController;
	}
	
	@Override
	public void mouseClicked(MouseEvent arg0) {
		
		System.out.println("Mouse clicked!");
		mainWindowController.setPositionX(arg0.getX());
		mainWindowController.setPositionY(arg0.getY());
//		mainWindowController.drawOverBackground(mainWindow.getCurrentStampImage().getImagePath());
		//mainWindowController.addOverScrImagePanel(mainWindow.getCurrentStampImage().getImagePath());
		mainWindowController.drawOverBackgroundFromPreview();
	}

	@Override
	public void mouseEntered(MouseEvent arg0) {
		
		 Toolkit kit = Toolkit.getDefaultToolkit();  
		 
		 if(mainWindow.getCurrentStampImage() == null)
		 {
			 mainWindow.getPnlImagePanel().setCursor(new Cursor(Cursor.CROSSHAIR_CURSOR));
		 }
		 else
		 {
		     Point point = new Point(16, 16); // Coordenada do clique em rela��o � imagem    
		     String nameCursor = "Image Cursor"; 
		     System.out.println(mainWindow.getCurrentStampImage().getImage().getHeight(null));
		     Cursor cursor = kit.createCustomCursor(mainWindow.getCurrentStampImage().getImage(), point, nameCursor);
		     mainWindow.getPnlImagePanel().setCursor(cursor);
		     
		 }
	}

	@Override
	public void mouseExited(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mousePressed(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void mouseReleased(MouseEvent arg0) {
		// TODO Auto-generated method stub
		
	}
	

	
}
